<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #box1 {
        height: 300px;
        width: 300px;
        border: 1px solid red;
        overflow: auto;
      }
      #box2 {
        height: 3000px;
        width: 3000px;
        border: 1px solid green;
      }
    </style>
    <script src="../jquery.min.js"></script>
    <script>
      $(function () {
        // 注意：scroll 一定要找准滚动容器，box2在box1里面，box2比box1大，box1装不下，就出现了滚动条，所以滚动容器是box1
        $('#box1').scrollTop()
        $('#box1').scrollLeft()
      })
    </script>
  </head>
  <body>
    <div id="box1">
      <div id="box2"></div>
    </div>
  </body>
</html>
